package org.test.java;

import org.junit.Test;

import java.io.BufferedReader;
import java.io.FileReader;

/**
 * @author liangcai_zhu
 * @Description TODO
 * @Date 2019/10/6 15:27
 */
public class StringUtil {

    /**
     * 去除字符串中的空格 去除特殊字符
     * @throws Exception
     */
    @Test
    public  void removeBlank() throws Exception{
        FileReader reader = new FileReader("test.sql");

        BufferedReader bufferedReader = new BufferedReader(reader);

        String s=null;
        while ((s=bufferedReader.readLine())!=null){
            System.out.println("转换前：" + s);
            //去除 '\n'  多个空格去除，一个空格的保留
            s = s.replace("\\n", "").replaceAll(" {2,}", "");
            System.out.println("转换后：" + s);
        }

    }

}
